home *** CD-ROM | disk | FTP | other *** search
- /* WinSNMP.h */
-
- /* WinSNMP API v1.0g, 9/13/93 */
-
- /* Author's Contact Information:
-
- Bob Natale
- Director, Network Management Products
- American Computer & Electronics Corp
- 209 Perry Parkway
- Gaithersburg MD 20877
- 301-258-9850 (tel)
- 301-921-0434 (fax)
- natale@acec.com (e-mail)
- */
-
- #ifndef _INC_WINSNMP
- #define _INC_WINSNMP /* Make sure we only do this once! */
-
- #include <windows.h> /* Include Windows Declarations */
-
- /* Windows-related types */
- typedef HANDLE HSNMP_SESSION, FAR *LPHSNMP_SESSION;
- typedef HANDLE HSNMP_ENTITY, FAR *LPHSNMP_ENTITY;
- typedef HANDLE HSNMP_CONTEXT, FAR *LPHSNMP_CONTEXT;
- typedef HANDLE HSNMP_PDU, FAR *LPHSNMP_PDU;
- typedef HANDLE HSNMP_VBL, FAR *LPHSNMP_VBL;
-
- /* The smiBYTE types are included to define smiOCTETS correctly */
- typedef unsigned char smiBYTE, FAR *smiLPBYTE;
- /* SNMP-related types from RFC1442 (SMI) */
- typedef signed long smiINT, FAR *smiLPINT;
- typedef smiINT smiINT32, FAR *smiLPINT32;
- typedef unsigned long smiUINT32, FAR *smiLPUINT32;
- typedef struct {
- smiUINT32 len;
- smiLPBYTE ptr;} smiOCTETS, FAR *smiLPOCTETS;
- typedef smiOCTETS smiBITS, FAR *smiLPBITS;
- typedef struct {
- smiUINT32 len;
- smiLPUINT32 ptr;} smiOID, FAR *smiLPOID;
- typedef smiOCTETS smiIPADDR, FAR *smiLPIPADDR;
- typedef smiUINT32 smiCNTR32, FAR *smiLPCNTR32;
- typedef smiUINT32 smiGAUGE32, FAR *smiLPGAUGE32;
- typedef smiUINT32 smiTIMETICKS, FAR *smiLPTIMETICKS;
- typedef smiOCTETS smiOPAQUE, FAR *smiLPOPAQUE;
- typedef smiOCTETS smiNSAPADDR, FAR *smiLPNSAPADDR;
- typedef struct {
- smiUINT32 hipart;
- smiUINT32 lopart;} smiCNTR64, FAR *smiLPCNTR64;
- /* ASN/BER Base Types */
- /* (used in forming SYNTAXes and certain SNMP types/values) */
- #define ASN_UNIVERSAL (0x00)
- #define ASN_APPLICATION (0x40)
- #define ASN_CONTEXT (0x80)
- #define ASN_PRIVATE (0xC0)
- #define ASN_PRIMITIVE (0x00)
- #define ASN_CONSTRUCTOR (0x20)
-
- /* SNMP ObjectSyntax Values */
- /* (used in the "syntax" member of the smiVALUE structure below) */
- #define SNMP_SYNTAX_INT (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x02)
- #define SNMP_SYNTAX_BITS (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
- #define SNMP_SYNTAX_OCTETS (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04)
- #define SNMP_SYNTAX_NULL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x05)
- #define SNMP_SYNTAX_OID (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x06)
- #define SNMP_SYNTAX_INT32 SNMP_SYNTAX_INT
- #define SNMP_SYNTAX_IPADDR (ASN_APPLICATION | ASN_PRIMITIVE | 0x00)
- #define SNMP_SYNTAX_CNTR32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x01)
- #define SNMP_SYNTAX_GAUGE32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x02)
- #define SNMP_SYNTAX_TIMETICKS (ASN_APPLICATION | ASN_PRIMITIVE | 0x03)
- #define SNMP_SYNTAX_OPAQUE (ASN_APPLICATION | ASN_PRIMITIVE | 0x04)
- #define SNMP_SYNTAX_NSAPADDR (ASN_APPLICATION | ASN_PRIMITIVE | 0x05)
- #define SNMP_SYNTAX_CNTR64 (ASN_APPLICATION | ASN_PRIMITIVE | 0x06)
- #define SNMP_SYNTAX_UINT32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x07)
- #define SNMP_SYNTAX_NOSUCHOBJECT SNMP_SYNTAX_NULL
- #define SNMP_SYNTAX_NOSUCHINSTANCE SNMP_SYNTAX_NULL
- #define SNMP_SYNTAX_ENDOFMIBVIEW SNMP_SYNTAX_NULL
-
- typedef struct { /* smiVALUE portion of VarBind */
- short type; /* Insert SNMP_SYNTAX_<type> */
- union {
- smiINT sNumber; /* SNMP_SYNTAX_INT
- SNMP_SYNTAX_INT32 */
- smiUINT32 uNumber; /* SNMP_SYNTAX_UINT32
- SNMP_SYNTAX_CNTR32
- SNMP_SYNTAX_GAUGE32
- SNMP_SYNTAX_TIMETICKS */
- smiCNTR64 hNumber; /* SNMP_SYNTAX_CNTR64 */
- smiOCTETS string; /* SNMP_SYNTAX_OCTETS
- SNMP_SYNTAX_BITS
- SNMP_SYNTAX_OPAQUE
- SNMP_SYNTAX_IPADDR
- SNMP_SYNTAX_NSAPADDR */
- smiOID oid; /* SNMP_SYNTAX_OID */
- smiBYTE empty; /* SNMP_SYNTAX_NULL
- SNMP_SYNTAX_NOSUCHOBJECT
- SNMP_SYNTAX_NOSUCHINSTANCE
- SNMP_SYNTAX_ENDOFMIBVIEW */
- } value;
- } smiVALUE, FAR *smiLPVALUE;
-
- /* SNMP Limits */
- #define MAXOBJIDSIZE 128 /* Max # of components in an OID */
- #define MAXOBJIDSTRSIZE 1408 /* Max # of bytes in decoded OID */
-
- /* PDU Type Values */
- #define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
- #define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
- #define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
- #define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
- /* This one is obsolete: (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) */
- #define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
- #define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
- #define SNMP_PDU_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
-
- /* SNMP Trap Values */
- #define SNMP_TRAP_COLDSTART 0
- #define SNMP_TRAP_WARMSTART 1
- #define SNMP_TRAP_LINKDOWN 2
- #define SNMP_TRAP_LINKUP 3
- #define SNMP_TRAP_AUTHFAIL 4
- #define SNMP_TRAP_EGPNEIGHBORLOSS 5
- #define SNMP_TRAP_ENTERPRISESPECIFIC 6
-
- /* Exception Values for Response Varbinds */
- #define SNMP_VALUE_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
- #define SNMP_VALUE_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
- #define SNMP_VALUE_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
-
- /* SNMP error codes returned in error_status field of PDU */
- /* These are NOT WinSNMP API error codes for SnmpGetLastError */
- /* Error codes common to SNMPv1 and SNMPv2 */
- #define SNMP_ERROR_NOERROR 0
- #define SNMP_ERROR_TOOBIG 1
- #define SNMP_ERROR_NOSUCHNAME 2
- #define SNMP_ERROR_BADVALUE 3
- #define SNMP_ERROR_READONLY 4
- #define SNMP_ERROR_GENERR 5
- /* Error codes added for SNMPv2 */
- #define SNMP_ERROR_NOACCESS 6
- #define SNMP_ERROR_WRONGTYPE 7
- #define SNMP_ERROR_WRONGLENGTH 8
- #define SNMP_ERROR_WRONGENCODING 9
- #define SNMP_ERROR_WRONGVALUE 10
- #define SNMP_ERROR_NOCREATION 11
- #define SNMP_ERROR_INCONSISTENTVALUE 12
- #define SNMP_ERROR_RESOURCEUNAVAILABLE 13
- #define SNMP_ERROR_COMMITFAILED 14
- #define SNMP_ERROR_UNDOFAILED 15
- #define SNMP_ERROR_AUTHORIZATIONERROR 16
- #define SNMP_ERROR_NOTWRITABLE 17
- #define SNMP_ERROR_INCONSISTENTNAME 18
-
- /* WinSNMP API values */
- /* Values used to indicate entity/context translation modes */
- #define SNMPAPI_NORMAL 0 /* Local Database look-up */
- #define SNMPAPI_UNTRANSLATED_V1 1 /* Raw v1 addressing */
- #define SNMPAPI_UNTRANSLATED_V2 2 /* Raw v2 addressing */
-
- /* Values used to indicate SNMP "communications level" */
- #define SNMPAPI_NO_SUPPORT 0 /* Encode/Decode msg */
- #define SNMPAPI_V1_SUPPORT 1 /* v1 agents too */
- #define SNMPAPI_V2_SUPPORT 2 /* v2 agents too */
- #define SNMPAPI_M2M_SUPPORT 3 /* Manager-to-Manager too */
-
- /* Values used to indicate retransmit mode */
- #define SNMPAPI_OFF 0 /* Refuse support */
- #define SNMPAPI_ON 1 /* Request support */
-
- /*WinSNMP API Function Return Codes */
- typedef smiUINT32 SNMPAPI_STATUS; /* Function return values */
- #define SNMPAPI_FAILURE 0 /* Generic error code */
- #define SNMPAPI_SUCCESS 1 /* Generic success code */
-
- /*WinSNMP API Error Codes (for SnmpGetLastError) */
- /* Error conditions reported by the API, other than SNMP Response-
- PDU error_status codes. */
- #define SNMPAPI_ALLOC_ERROR 2 /* Error allocating memory */
- #define SNMPAPI_CONTEXT_INVALID 3 /* Invalid context parameter */
- #define SNMPAPI_CONTEXT_UNKNOWN 4 /* Unknown context parameter */
- #define SNMPAPI_ENTITY_INVALID 5 /* Invalid entity parameter */
- #define SNMPAPI_ENTITY_UNKNOWN 6 /* Unknown entity parameter */
- #define SNMPAPI_INDEX_INVALID 7 /* Invalid index parameter */
- #define SNMPAPI_NOOP 8 /* No operation performed */
- #define SNMPAPI_OID_INVALID 9 /* Invalid OID parameter */
- #define SNMPAPI_OPERATION_INVALID 10 /* Invalid/unsupported operation */
- #define SNMPAPI_OUTPUT_TRUNCATED 11 /* Insufficient output buf size */
- #define SNMPAPI_PDU_INVALID 12 /* Invalid PDU parameter */
- #define SNMPAPI_SESSION_INVALID 13 /* Invalid session parameter */
- #define SNMPAPI_SYNTAX_INVALID 14 /* Invalid syntax in smiVALUE */
- #define SNMPAPI_VBL_INVALID 15 /* Invalid VBL parameter */
- #define SNMPAPI_MODE_INVALID 16 /* Invalid mode parameter */
- #define SNMPAPI_SIZE_INVALID 17 /* Invalid size/length parameter */
- #define SNMPAPI_NOT_INITIALIZED 18 /* SnmpStartup missing/failed */
- #define SNMPAPI_MESSAGE_INVALID 19 /* Invalid SNMP message format */
- #define SNMPAPI_OTHER_ERROR 99 /* Internal/undefined error */
- /* Others will be added as needed */
-
- /* WinSNMP API Function Prototypes */
- #define IN /* Documentation only */
- #define OUT /* Documentation only */
- #define SNMPAPI_CALL WINAPI /* FAR PASCAL calling conventions */
-
- /* Local Database Functions */
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpGetTranslateMode
- (OUT smiLPUINT32 nTranslateMode);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpSetTranslateMode
- (IN smiUINT32 nTranslateMode);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpGetRetransmitMode
- (OUT smiLPUINT32 nRetransmitMode);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpSetRetransmitMode
- (IN smiUINT32 nRetransmitMode);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpGetTimeout
- (IN HSNMP_ENTITY hEntity,
- OUT smiLPTIMETICKS nPolicyTimeout,
- OUT smiLPTIMETICKS nActualTimeout);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpSetTimeout
- (IN HSNMP_ENTITY hEntity,
- IN smiTIMETICKS nPolicyTimeout);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpGetRetry
- (IN HSNMP_ENTITY hEntity,
- OUT smiLPUINT32 nPolicyRetry,
- OUT smiLPUINT32 nActualRetry);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpSetRetry
- (IN HSNMP_ENTITY hEntity,
- IN smiUINT32 nPolicyRetry);
-
- /* Communications Functions */
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpStartup
- (OUT smiLPUINT32 nMajorVersion,
- OUT smiLPUINT32 nMinorVersion,
- OUT smiLPUINT32 nLevel,
- OUT smiLPUINT32 nTranslateMode,
- OUT smiLPUINT32 nRetransmitMode);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpCleanup
- (void);
-
- HSNMP_SESSION SNMPAPI_CALL SnmpOpen
- (IN HWND hWnd,
- IN UINT wMsg);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpClose
- (IN HSNMP_SESSION session);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpSendMsg
- (IN HSNMP_SESSION session,
- IN HSNMP_ENTITY srcEntity,
- IN HSNMP_ENTITY dstEntity,
- IN HSNMP_CONTEXT context,
- IN HSNMP_PDU PDU);
-
- HSNMP_PDU SNMPAPI_CALL SnmpRecvMsg
- (IN HSNMP_SESSION session,
- OUT LPHSNMP_ENTITY srcEntity,
- OUT LPHSNMP_CONTEXT context);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpRegister
- (IN HSNMP_SESSION session,
- IN HSNMP_ENTITY srcEntity,
- IN HSNMP_ENTITY dstEntity,
- IN HSNMP_CONTEXT context,
- IN smiLPOID notification,
- IN BOOL enabled);
-
- /* Entity/Context Functions */
-
- HSNMP_ENTITY SNMPAPI_CALL SnmpStrToEntity
- (IN HSNMP_SESSION session,
- IN LPSTR entity);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpEntityToStr
- (IN HSNMP_ENTITY entity,
- IN smiUINT32 size,
- OUT LPSTR string);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpFreeEntity
- (IN HSNMP_ENTITY entity);
-
- HSNMP_CONTEXT SNMPAPI_CALL SnmpStrToContext
- (IN HSNMP_SESSION session,
- IN HSNMP_ENTITY entity,
- IN LPSTR context);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpContextToStr
- (IN HSNMP_CONTEXT context,
- IN smiUINT32 size,
- OUT LPSTR string);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpFreeContext
- (IN HSNMP_CONTEXT context);
-
- /* PDU Functions */
-
- /*
- Note that in the SnmpCreatePdu, SnmpGetPduData, and SnmpSetPduData
- functions the error_status and error_index parameters can also be
- used as non_repeaters and max_repetitions parameters when
- appropriate, and vice versa.
- */
-
- HSNMP_PDU SNMPAPI_CALL SnmpCreatePdu
- (IN HSNMP_SESSION session,
- IN smiINT PDU_type,
- IN smiINT32 request_id,
- IN smiINT error_status,
- IN smiINT error_index,
- IN HSNMP_VBL varbindlist);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpGetPduData
- (IN HSNMP_PDU PDU,
- OUT smiLPINT PDU_type,
- OUT smiLPINT32 request_id,
- OUT smiLPINT error_status,
- OUT smiLPINT error_index,
- OUT LPHSNMP_VBL varbindlist);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpSetPduData
- (IN HSNMP_PDU PDU,
- IN smiLPINT PDU_type,
- IN smiLPINT32 request_id,
- IN smiLPINT non_repeaters,
- IN smiLPINT max_repetitions,
- IN LPHSNMP_VBL varbindlist);
-
- HSNMP_PDU SNMPAPI_CALL SnmpDuplicatePdu
- (IN HSNMP_SESSION session,
- IN HSNMP_PDU PDU);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpFreePdu
- (IN HSNMP_PDU PDU);
-
- /* Variable-Binding Functions */
-
- HSNMP_VBL SNMPAPI_CALL SnmpCreateVbl
- (IN HSNMP_SESSION session,
- IN smiLPOID name,
- IN smiLPVALUE value);
-
- HSNMP_VBL SNMPAPI_CALL SnmpDuplicateVbl
- (IN HSNMP_SESSION session,
- IN HSNMP_VBL vbl);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpFreeVbl
- (IN HSNMP_VBL vbl);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpCountVbl
- (IN HSNMP_VBL vbl);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpGetVb
- (IN HSNMP_VBL vbl,
- IN smiUINT32 index,
- OUT smiLPOID name,
- OUT smiLPVALUE value);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpSetVb
- (IN HSNMP_VBL vbl,
- IN smiLPOID name,
- IN smiLPVALUE value);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpDeleteVb
- (IN HSNMP_VBL vbl,
- IN smiLPOID name);
-
- /* Utility Functions */
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpGetLastError
- (IN HSNMP_SESSION session);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpStrToOid
- (IN LPSTR string,
- IN OUT smiLPOID dstOID);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpOidToStr
- (IN smiLPOID srcOID,
- IN smiUINT32 size,
- OUT LPSTR string);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpOidCopy
- (IN smiLPOID srcOID,
- IN OUT smiLPOID dstOID);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpOidCompare
- (IN smiLPOID xOID,
- IN smiLPOID yOID,
- IN smiUINT32 maxlen,
- OUT smiLPINT result);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpEncodeMsg
- (IN HSNMP_SESSION session,
- IN HSNMP_ENTITY srcEntity,
- IN HSNMP_ENTITY dstEntity,
- IN HSNMP_CONTEXT context,
- IN HSNMP_PDU pdu,
- IN OUT smiLPOCTETS msgBufDesc);
-
- SNMPAPI_STATUS SNMPAPI_CALL SnmpDecodeMsg
- (IN HSNMP_SESSION session,
- OUT LPHSNMP_ENTITY srcEntity,
- OUT LPHSNMP_ENTITY dstEntity,
- OUT LPHSNMP_CONTEXT context,
- OUT LPHSNMP_PDU pdu,
- IN smiLPOCTETS msgBufDesc);
-
- #endif /* _INC_WINSNMP */
-